/**
 * 入口文件
 * 1.运行指令
 * 	开发环境：webpack ./src/index.js -o ./build/built.js --mode=development
 *  webpack会以 ./src/index.js 为入口文件开始打包，输出到 ./build/built.js 打包环境是 开发环境
 * 	生产环境：webpack ./src/index.js -o ./build/built.js --mode=production
 * 
 * webpack 能处理js/json，不能处理css/img等其他资源
 * 
 */
// 完整引入
// import 'core-js'
// 按需加载
// import 'core-js/es/promise'


import './index.css'
import './index.less'
import './index.scss'
import './index.sass'
import './css/iconfont.css'
import {
	add,
	mul
} from "./js/sum.js"
console.log(mul(2, 2))

import data from './data.json'
console.log(data)

let a = 1
console.log(a)

console.log(add(1, 2))
console.log(add(2, 3))

let testfun = () => {
	console.log('testfun')
}

testfun()

if (module.hot) {
	// 判断是否支持热模块替换
	module.hot.accept("./js/sum.js")
}

document.querySelector('#btn').onclick = function() {
	import( /* webpackChunkName: "aaa" */ './js/aaa.js').then(res => {
		res.default(1, 1)
	})
}

new Promise((resolve) => {
	resolve()
})

const arr = [1, 2, 3]
console.log(arr.includes(2))

if ('serviceWorker' in navigator) {
	window.addEventListener('load', () => {
		navigator.serviceWorker.register('/service-worker.js').then(registration => {
			console.log('SW registered: ', registration);
		}).catch(registrationError => {
			console.log('SW registration failed: ', registrationError);
		});
	});
}
